<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcai: lib/cai.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libcai
   </div>
   <div id="projectbrief">大模型在线推理C语言函数库</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_97aefd0d527b934f1d99a682da8fe6a9.html">lib</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">cai.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="cai_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef CAI_H</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define CAI_H</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; </div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="keyword">struct </span>cai_convo;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; </div>
<div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="cai_8h.html#afcda987a680fdb35bc441cdd42ffa874">   16</a></span>&#160;<span class="keyword">struct </span>cai_convo* <a class="code" href="cai_8h.html#afcda987a680fdb35bc441cdd42ffa874">cai_convo_create</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* prompt, <span class="keywordtype">int</span> max);</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="cai_8h.html#a94ca6ff9ef763a7171eba6ae4a49b363">   23</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="cai_8h.html#a94ca6ff9ef763a7171eba6ae4a49b363">cai_convo_destroy</a>(<span class="keyword">struct</span> cai_convo* convo);</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="cai_8h.html#a3c75f1ff8b6f71383638e418a660a980">   31</a></span>&#160;<span class="keyword">struct </span>cai_convo* <a class="code" href="cai_8h.html#a3c75f1ff8b6f71383638e418a660a980">cai_convo_load</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* file);</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160; </div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="cai_8h.html#a2efe9210138bbc4caca08370faf3e0e0">   40</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="cai_8h.html#a2efe9210138bbc4caca08370faf3e0e0">cai_convo_save</a>(<span class="keyword">struct</span> cai_convo* convo, <span class="keyword">const</span> <span class="keywordtype">char</span>* file);</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; </div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword">struct </span>cai_asst;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160; </div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="cai_8h.html#a3e13b5d6ba406a91e31885de87ff329b">   55</a></span>&#160;<span class="keyword">struct </span>cai_asst* <a class="code" href="cai_8h.html#a3e13b5d6ba406a91e31885de87ff329b">cai_asst_create</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* api_key, <span class="keyword">const</span> <span class="keywordtype">char</span>* base_url, <span class="keyword">const</span> <span class="keywordtype">char</span>* model);</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160; </div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="cai_8h.html#a3a8fccff87a9ceb0f2b9d88988794372">   62</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="cai_8h.html#a3a8fccff87a9ceb0f2b9d88988794372">cai_asst_destroy</a>(<span class="keyword">struct</span> cai_asst* asst);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="cai_8h.html#aa0345f8fbe1dcd7b536c6f7457702777">   70</a></span>&#160;<span class="keyword">typedef</span> void (*<a class="code" href="cai_8h.html#aa0345f8fbe1dcd7b536c6f7457702777">cai_stream_callback</a>)(<span class="keywordtype">void</span>* userdata, <span class="keywordtype">char</span>* content, <span class="keywordtype">char</span>* reason);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160; </div>
<div class="line"><a name="l00079"></a><span class="lineno"><a class="line" href="cai_8h.html#a85b6aeb892a8e4725274ea2b8cde2c60">   79</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="cai_8h.html#a85b6aeb892a8e4725274ea2b8cde2c60">cai_set_stream_callback</a>(<span class="keyword">struct</span> cai_asst* asst, <a class="code" href="cai_8h.html#aa0345f8fbe1dcd7b536c6f7457702777">cai_stream_callback</a> callback, <span class="keywordtype">void</span>* userdata);</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160; </div>
<div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="cai_8h.html#a38fc36d328aefa41f86c335961483235">   90</a></span>&#160;<span class="keywordtype">char</span>* <a class="code" href="cai_8h.html#a38fc36d328aefa41f86c335961483235">cai_asst_chat</a>(<span class="keyword">struct</span> cai_asst* asst, </div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;                    <span class="keyword">struct</span> cai_convo* conv, </div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;                    <span class="keyword">const</span> <span class="keywordtype">char</span>* question,</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;                    <span class="keyword">const</span> <span class="keywordtype">char</span>* file);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="acai_8h_html_a2efe9210138bbc4caca08370faf3e0e0"><div class="ttname"><a href="cai_8h.html#a2efe9210138bbc4caca08370faf3e0e0">cai_convo_save</a></div><div class="ttdeci">int cai_convo_save(struct cai_convo *convo, const char *file)</div><div class="ttdoc">将对话上下文保存到文件中</div></div>
<div class="ttc" id="acai_8h_html_a38fc36d328aefa41f86c335961483235"><div class="ttname"><a href="cai_8h.html#a38fc36d328aefa41f86c335961483235">cai_asst_chat</a></div><div class="ttdeci">char * cai_asst_chat(struct cai_asst *asst, struct cai_convo *conv, const char *question, const char *file)</div><div class="ttdoc">与AI助手对话</div></div>
<div class="ttc" id="acai_8h_html_a3a8fccff87a9ceb0f2b9d88988794372"><div class="ttname"><a href="cai_8h.html#a3a8fccff87a9ceb0f2b9d88988794372">cai_asst_destroy</a></div><div class="ttdeci">void cai_asst_destroy(struct cai_asst *asst)</div><div class="ttdoc">删除AI助手</div></div>
<div class="ttc" id="acai_8h_html_a3c75f1ff8b6f71383638e418a660a980"><div class="ttname"><a href="cai_8h.html#a3c75f1ff8b6f71383638e418a660a980">cai_convo_load</a></div><div class="ttdeci">struct cai_convo * cai_convo_load(const char *file)</div><div class="ttdoc">从文件中加载对话上下文</div></div>
<div class="ttc" id="acai_8h_html_a3e13b5d6ba406a91e31885de87ff329b"><div class="ttname"><a href="cai_8h.html#a3e13b5d6ba406a91e31885de87ff329b">cai_asst_create</a></div><div class="ttdeci">struct cai_asst * cai_asst_create(const char *api_key, const char *base_url, const char *model)</div><div class="ttdoc">创建AI助手</div></div>
<div class="ttc" id="acai_8h_html_a85b6aeb892a8e4725274ea2b8cde2c60"><div class="ttname"><a href="cai_8h.html#a85b6aeb892a8e4725274ea2b8cde2c60">cai_set_stream_callback</a></div><div class="ttdeci">void cai_set_stream_callback(struct cai_asst *asst, cai_stream_callback callback, void *userdata)</div><div class="ttdoc">设置流式响应回调函数</div></div>
<div class="ttc" id="acai_8h_html_a94ca6ff9ef763a7171eba6ae4a49b363"><div class="ttname"><a href="cai_8h.html#a94ca6ff9ef763a7171eba6ae4a49b363">cai_convo_destroy</a></div><div class="ttdeci">void cai_convo_destroy(struct cai_convo *convo)</div><div class="ttdoc">删除对话</div></div>
<div class="ttc" id="acai_8h_html_aa0345f8fbe1dcd7b536c6f7457702777"><div class="ttname"><a href="cai_8h.html#aa0345f8fbe1dcd7b536c6f7457702777">cai_stream_callback</a></div><div class="ttdeci">void(* cai_stream_callback)(void *userdata, char *content, char *reason)</div><div class="ttdoc">流式响应回调函数原型</div><div class="ttdef"><b>Definition:</b> cai.h:70</div></div>
<div class="ttc" id="acai_8h_html_afcda987a680fdb35bc441cdd42ffa874"><div class="ttname"><a href="cai_8h.html#afcda987a680fdb35bc441cdd42ffa874">cai_convo_create</a></div><div class="ttdeci">struct cai_convo * cai_convo_create(const char *prompt, int max)</div><div class="ttdoc">新建对话</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
